package com.zhongwang.business.module.estimateBudgetAccountingManage.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zhongwang.business.base.BaseController;
import com.zhongwang.business.common.JsonResult;
import com.zhongwang.business.gen.entity.BusBudgetAccountingBasicInfoConfig;
import com.zhongwang.business.gen.entity.BusBudgetAccountingCost;
import com.zhongwang.business.gen.entity.BusBudgetAccountingTask;
import com.zhongwang.business.gen.entity.BusMaterialData;
import com.zhongwang.business.module.contractManage.model.ConContractMainModel;
import com.zhongwang.business.module.estimateBudgetAccountingManage.model.*;
import com.zhongwang.business.module.estimateBudgetAccountingManage.model.excelImport.*;
import com.zhongwang.business.module.estimateBudgetAccountingManage.service.AccountingService;
import com.zhongwang.business.module.estimateBudgetAccountingManage.service.EstimateService;
import com.zhongwang.business.module.estimateBudgetAccountingManage.service.GetDataService;
import com.zhongwang.business.util.BeanUtil;
import com.zhongwang.business.util.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 徐一贺
 * @className EstimateController 概算控制层
 * @date 2020/12/11 16:30
 * @versron ver 1.0
 */
@Controller
@RequestMapping("/estimateManage")
public class EstimateController extends BaseController {
    @Autowired
    private GetDataService getDataService;
    @Autowired
    private AccountingService accountingService;
    @Autowired
    private EstimateService estimateService;
    /**
     *  page
     *  跳转页面
     * @param model 页面渲染模型
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020年12月11日16:35:09
     * @version 1.0
     */
    @GetMapping
    @RequiresPermissions("rou:list:view")
    public String page(Model model){
        //获取工作组列表
        List<BusinessGroupModel> groupModelList = accountingService.findBusinessGroupList();
        model.addAttribute("groupModelList",groupModelList);
        return "estimateManage/list/page";
    }

    /**  list 获取项目概算列表
     * @param param 检索参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/11 16:54
     */
    @ResponseBody
    @PostMapping("/list")
    public JsonResult list(AccountingProjectModel param){
        startPage();
        return jsonResult(estimateService.list(param));
    }

    /**  submitList 跳转到概算提交列表
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020/12/22 8:09
     */
    @GetMapping("/submitList")
    public String submitList(){
        return "estimateManage/submit/page";
    }

    /**  switchList 选择样机项目列表
     * @param param 检索参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/11 18:40
     */
    @ResponseBody
    @PostMapping("/switchList")
    public JsonResult switchList(AccountingProjectModel param){
        startPage();
        return jsonResult(estimateService.switchList(param));
    }

    /**  viewCostSheet 根据单据表主键显示核算完成的成本清单
     * @param batId 单据表主键
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020/12/12 8:27
     */
    @GetMapping("/viewCostSheet/{batId}/{proCode}/{taskId}")
    public String  viewCostSheet(@PathVariable("batId") Integer batId,
                                 @PathVariable("proCode") String proCode,
                                 @PathVariable("taskId") Integer taskId,
                                 Model model){
        BusBudgetAccountingTaskModel order = accountingService.getBusBudgetAccountingTaskAndAppInfoByPrimaryKey(batId);
        List<BusBudgetAccountingCost> costList = accountingService.findShowBusBudgetAccountingCostByBatId(batId);
        //基础参数数据
        List<BusBudgetAccountingBasicInfoConfig> busBudgetAccountingBasicInfoConfigList = getDataService.findBusBudgetAccountingBasicInfoConfigByBatId(batId);
        //获取核算设备总重
        BigDecimal equipmentTotalWeight = getDataService.getAccountingEquipmentTotalWeightByBatId(batId);
        //获取核算设备净重
        BigDecimal equipmentTotalNetWeight = getDataService.getAccountingEquipmentTotalNetWeightByBatId(batId);
        //获取合同信息
        ConContractMainModel contract = getDataService.getConContractMainModelByCode(order.getProCode());
        ProjectModel project = getDataService.getProjectModel(order.getProCode());
        ProjectModel estProject = getDataService.getProjectModel(proCode);
        model.addAttribute("order", order);
        model.addAttribute("taskId", taskId);
        model.addAttribute("contract", contract);
        model.addAttribute("project", project);
        model.addAttribute("estProject", estProject);
        model.addAttribute("busBudgetAccountingCosts", costList);
        model.addAttribute("busBudgetAccountingBasicInfoConfigList", busBudgetAccountingBasicInfoConfigList);
        model.addAttribute("equipmentTotalWeight", equipmentTotalWeight);
        model.addAttribute("equipmentTotalNetWeight", equipmentTotalNetWeight);
        return "estimateManage/viewAccountCostSheet/page";
    }

    /**  createEst 创建概算
     * @param param 概算信息
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/17 17:58
     */
    @ResponseBody
    @PostMapping("/createEst")
    public JsonResult createEst(BusBudgetAccountingTaskModel param){
        return estimateService.createEst(param);
    }

    /**  titleExist 验证该项下的概算名称是否重复
     * @param param 项目号和title
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020/12/18 10:34
     */
    @ResponseBody
    @PostMapping("/titleExist")
    public String titleExist(BusBudgetAccountingTaskModel param) {
        Map<String, Boolean> map = new HashMap<String, Boolean>();
        map.put("valid", estimateService.titleExist(param));
        String resultString = "";
        ObjectMapper mapper = new ObjectMapper();
        try {
            resultString = mapper.writeValueAsString(map);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return resultString;
    }

    /**  loadPrototypeInfo 获取样机信息
     * @param param 样机项目号
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/21 10:40
     */
    @ResponseBody
    @PostMapping("/loadPrototypeInfo")
    public JsonResult loadPrototypeInfo(BusBudgetAccountingTaskModel param) {
        Map<String,Object> map = new HashMap<String,Object>();
        //获取合同信息
        ConContractMainModel contract = getDataService.getConContractMainModelByCode(param.getProCode());
        map.put("contract",contract);
        //获取样机项目信息
        VwProjectModel vwProject = estimateService.getVwProjectByCode(param.getProCode());
        map.put("project",vwProject);
        //获取样机金额
        BigDecimal amount = estimateService.getPrototypeAmountByProCode(param.getProCode());
        map.put("amount",amount);
        return success().setData(map);
    }

    /**  jumpCreateEstPage 跳转到创建概算页面
     * @param proCode xiangmuhao
     * @param model 页面渲染模型
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020/12/21 14:58
     */
    @GetMapping("/jumpCreateEstPage/{proCode}/{tid}")
    public String jumpCreateEstPage(@PathVariable("proCode") String proCode,@PathVariable("tid") Integer tid,Model model){
        VwProjectModel vwProject = estimateService.getVwProjectByCode(proCode);
        model.addAttribute("project",vwProject);
        model.addAttribute("taskId",tid);
        return "estimateManage/list/createPage";
    }

    /**  checkCurrentDept 该概算是否是他部门的概算。是否是他的概算，是否有概算
     * @param param 概算项目项目编号
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/21 16:20
     */
    @ResponseBody
    @PostMapping("/checkCurrentDept")
    public JsonResult checkCurrentDept(BusBudgetAccountingTaskModel param){
        return estimateService.checkCurrentDept(param);
    }

    /**  editEstCostSheet 跳转到概算调整页面
     * @param batId
     * @return java.lang.String
     * @exception
     * @author 徐一贺
     * @date 2020/12/21 18:01
     */
    @GetMapping("/editEstCostSheet/{batId}")
    public String editEstCostSheet(@PathVariable("batId") Integer batId,Model model){
        ProjectModel project = estimateService.getProjectModelBybatId(batId);
        model.addAttribute("project", project);
        model.addAttribute("batId",batId);
        return "estimateManage/editCostSheet/page";
    }

    /**  viewInfo 跳转到明细页
     * @param mode 查看页面方式,edit是编辑，此模式可以查看编辑等所有操作，see是查看和审核只能查看和审核，print是打印只能查看清单，无法查看明细
     * @param costId 成本项主键
     * @param model 页面渲染模型
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020/12/22 7:53
     */
    @GetMapping("/viewInfo/{mode}/{costId}")
    public String viewInfo(@PathVariable("mode") String mode,@PathVariable("costId") Integer costId,Model model){
        BusBudgetAccountingCostModel cost = estimateService.getBusBudgetAccountingCostByPrimaryKey(costId);
        BusBudgetAccountingTaskModel order = estimateService.getBusBudgetAccountingTaskByPrimaryKey(cost.getBatId());
        VwProjectModel projectModel = estimateService.getVwProjectByCode(order.getProCode());
        model.addAttribute("mode",mode);
        model.addAttribute("project",projectModel);
        model.addAttribute("cost",cost);
        String texture = null;
        if(cost.getCode().contains("-材料费-材料采购费-")){
            texture = cost.getCode().substring(cost.getCode().lastIndexOf("-")+1);
        }
        model.addAttribute("texture",texture);
        return "estimateManage/infoPage/page";
    }

    /**  findSubmitList 加载概算待提交列表
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/22 8:17
     */
    @ResponseBody
    @PostMapping("/findSubmitList")
    public JsonResult findSubmitList(AccountingProjectModel param) {
        startPage();
        return jsonResult(estimateService.findSubmitList(param));
    }

    /**  saveOrder 保存概算清单
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/22 8:46
     */
    @ResponseBody
    @PostMapping("/saveOrder")
    @RequiresPermissions(value = {"rou:submit:commit"})
    public JsonResult saveOrder(BusBudgetAccountingTask param) {
        return estimateService.saveOrder(param);
    }

    /**  checkIsSave 检测概算清单是否保存过
     * @param param 主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/22 9:10
     */
    @ResponseBody
    @PostMapping("/checkIsSave")
    public JsonResult checkIsSave(BusBudgetAccountingTask param) {
        return estimateService.checkIsSave(param);
    }
    /**  removeOrder 删除此概算
     * @param param 概算主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/23 11:11
     */
    @ResponseBody
    @PostMapping("/removeOrder")
    public JsonResult removeOrder(BusBudgetAccountingTask param) {
        return estimateService.removeOrder(param);
    }

    /**  loadCostSheet 加载概算列表
     * @param batId 单据表主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/23 14:00
     */
    @ResponseBody
    @PostMapping("/loadCostSheet")
    public JsonResult loadCostSheet(Integer batId){
        return success().setData(estimateService.loadCostSheet(batId));
    }
    /**
     * findApprovalList 获取概算成本清单提审核表
     *
     * @param param 参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/11/25 8:47
     * @version 1.0
     */
    @ResponseBody
    @PostMapping("/findApprovalList")
    public JsonResult findApprovalList(AccountingProjectModel param) {
        startPage();
        return jsonResult(estimateService.findApprovalList(param));
    }

    /**  loadWeightParams 根据单据表主键加载重量参数
     * @param batId 单据表主键
     * @return com.zhongwang.business.common.JsonResult
     * @exception
     * @author 徐一贺
     * @date 2020/12/7 16:33
     */
    @ResponseBody
    @PostMapping("/loadWeightParams")
    public JsonResult loadWeightParams(Integer batId){
        return success().setData(estimateService.loadWeightParams(batId));
    }
    /**  startEstimating 一键概算
     * @param batId 单据表主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/23 15:24
     */
    @ResponseBody
    @PostMapping("/startEstimating")
    public JsonResult startEstimating(Integer batId){
        return estimateService.oneClickBudgetEstimate(batId);
    }

    /**  changeIsEffectiveFlag 数据有效无效操作
     * @param param 参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 9:20
     */
    @ResponseBody
    @PostMapping("/changeIsEffectiveFlagByMat")
    public JsonResult changeIsEffectiveFlagByMat(ChangeIsEffectiveFlagModel param){
        if(estimateService.changeIsEffectiveFlagByMat(param)>0){
            return success("操作成功！");
        }
        return error("操作失败！");
    }
    /**  changeIsEffectiveFlagByMan 数据有效无效操作
     * @param param 参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 9:20
     */
    @ResponseBody
    @PostMapping("/changeIsEffectiveFlagByMan")
    public JsonResult changeIsEffectiveFlagByMan(ChangeIsEffectiveFlagModel param){
        if(estimateService.changeIsEffectiveFlagByMan(param)>0){
            return success("操作成功！");
        }
        return error("操作失败！");
    }
    /**  changeIsEffectiveFlagByMac 机加数据有效无效操作
     * @param param 参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 20:08
     */
    @ResponseBody
    @PostMapping("/changeIsEffectiveFlagByMac")
    public JsonResult changeIsEffectiveFlagByMac(ChangeIsEffectiveFlagModel param){
        if(estimateService.changeIsEffectiveFlagByMac(param)>0){
            return success("操作成功！");
        }
        return error("操作失败！");
    }
    /**  removeMat 根据主键们删除原材料数据
     * @param param 主键们
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 10:02
     */
    @ResponseBody
    @PostMapping("/removeMat")
    public JsonResult removeMat(ChangeIsEffectiveFlagModel param){
        Integer res = estimateService.removeMat(param);
        if(res == 1){
            return success("操作成功！");
        }else if(res == -1){
            return success("数据已删除，操作成功！");
        }
        return error("操作失败！");
    }
    /**  removeMan 根据主键们删除工时辅材运费数据
     * @param param 主键们
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 19:40
     */
    @ResponseBody
    @PostMapping("/removeMan")
    public JsonResult removeMan(ChangeIsEffectiveFlagModel param){
        Integer res = estimateService.removeMan(param);
        if(res == 1){
            return success("操作成功！");
        }else if(res == -1){
            return success("数据已删除，操作成功！");
        }
        return error("操作失败！");
    }
    /**  removeMac 根据主键们删除机加工时
     * @param param 主键们
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 19:40
     */
    @ResponseBody
    @PostMapping("/removeMac")
    public JsonResult removeMac(ChangeIsEffectiveFlagModel param){
        Integer res = estimateService.removeMac(param);
        if(res == 1){
            return success("操作成功！");
        }else if(res == -1){
            return success("数据已删除，操作成功！");
        }
        return error("操作失败！");
    }

    /**  clearMat 根据成本项主键清空改成本项原材料数据
     * @param param 成本项主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 12:54
     */
    @ResponseBody
    @PostMapping("/clearMat")
    public JsonResult clearMat(BusMaterialDataModel param){
        Integer res = estimateService.clearMat(param);
        if(res == 1){
            return success("操作成功！");
        }else if(res == -1){
            return success("数据已清空，操作成功！");
        }
        return error("操作失败！");
    }
    /**  clearMat 根据成本项主键清空改成本项工时辅材运费数据
     * @param param 成本项主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 12:54
     */
    @ResponseBody
    @PostMapping("/clearHours")
    public JsonResult clearHours(BusMaterialDataModel param){
        Integer res = estimateService.clearHours(param);
        if(res == 1){
            return success("操作成功！");
        }else if(res == -1){
            return success("数据已清空，操作成功！");
        }
        return error("操作失败！");
    }
    /**  clearHoursMac 清空机加数据
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 20:31
     */
    @ResponseBody
    @PostMapping("/clearHoursMac")
    public JsonResult clearHoursMac(BusMaterialDataModel param){
        Integer res = estimateService.clearHoursMac(param);
        if(res == 1){
            return success("操作成功！");
        }else if(res == -1){
            return success("数据已清空，操作成功！");
        }
        return error("操作失败！");
    }

    /**  rawMaterialList 获取概算原材料明细数据
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 13:22
     */
    @ResponseBody
    @PostMapping("/rawMaterialList")
    public JsonResult rawMaterialList(BusMaterialData param) {
        startPage();
        return jsonResult(estimateService.rawMaterialList(param));
    }

    /**  matSaveAdd 添加原材料
     * @param data 数据
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/24 18:39
     */
    @ResponseBody
    @PostMapping("/matSaveAdd")
    public JsonResult matSaveAdd(BusMaterialDataModel data){
        Integer result = estimateService.matSaveAdd(data);
        if(result > 0){
            return success("添加成功！");
        }
        return error("添加失败！");
    }

    /**  wholeSaveAdd 添加整体外协
     * @param data
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 12:58
     */
    @ResponseBody
    @PostMapping("/wholeSaveAdd")
    public JsonResult wholeSaveAdd(BusMaterialDataModel data){
        Integer result = estimateService.wholeSaveAdd(data);
        if(result > 0){
            return success("操作成功！");
        }
        return error("操作失败！");
    }
    /**  wholeSaveAdd 添加带料外协
     * @param data
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 12:58
     */
    @ResponseBody
    @PostMapping("/whithMatSaveAdd")
    public JsonResult whithMatSaveAdd(BusMaterialDataModel data){
        Integer result = estimateService.whithMatSaveAdd(data);
        if(result > 0){
            return success("添加成功！");
        }
        return error("添加失败！");
    }

    /**  deferralExport 导出原材料样机数据
     * @param response
     * @param param 条件
     * @author 徐一贺
     * @date 2020/12/24 19:06
     */
    @ResponseBody
    @GetMapping("/matExport")
    public void matExport(HttpServletResponse response, BusMaterialDataModel param) {
        estimateService.matExport(response, param);
    }
    /**  deferralExport 导出外购费样机数据
     * @param response
     * @param param 条件
     * @author 徐一贺
     * @date 2020/12/24 19:06
     */
    @ResponseBody
    @GetMapping("/purExport")
    public void purExport(HttpServletResponse response, BusMaterialDataModel param) {
        estimateService.purExport(response, param);
    }
    /**  wholeExport 导出整体外协样机数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/4 13:55
     */
    @ResponseBody
    @GetMapping("/wholeExport")
    public void wholeExport(HttpServletResponse response, BusMaterialDataModel param) {
        estimateService.wholeExport(response, param);
    }
    /**  withMatExport 导出带料外协样机数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/4 14:04
     */
    @ResponseBody
    @GetMapping("/withMatExport")
    public void withMatExport(HttpServletResponse response, BusMaterialDataModel param) {
        estimateService.withMatExport(response, param);
    }
    /**  matExport 导出铝材样机数
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/28 9:42
     */
    @ResponseBody
    @GetMapping("/aluExport")
    public void aluExport(HttpServletResponse response, BusMaterialDataModel param) {
        estimateService.aluExport(response, param);
    }
    /**  cutExport 导出下料样机工时数据
     * @param response
     * @param param 条件
     * @author 徐一贺
     * @date 2020/12/24 19:06
     */
    @ResponseBody
    @GetMapping("/cutExport")
    public void cutExport(HttpServletResponse response, BusGeneralHoursModel param) {
        estimateService.cutExport(response, param);
    }
    /**  cutAuxExport 导出下料样机辅材数据
     * @param response
     * @param param 条件
     * @author 徐一贺
     * @date 2020/12/24 19:06
     */
    @ResponseBody
    @GetMapping("/cutAuxExport")
    public void cutAuxExport(HttpServletResponse response, BusGeneralHoursModel param) {
        estimateService.cutAuxExport(response, param);
    }
    /**  rivetAndSolderExport 导出铆焊样机工时数据
     * @param response
     * @param param 条件
     * @author 徐一贺
     * @date 2020/12/24 19:06
     */
    @ResponseBody
    @GetMapping("/rivetAndSolderExport")
    public void rivetAndSolderExport(HttpServletResponse response, BusGeneralHoursModel param) {
        estimateService.rivetAndSolderExport(response, param);
    }
    /**  sprayExport 导出喷涂样机工时数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 11:17
     */
    @ResponseBody
    @GetMapping("/sprayExport")
    public void sprayExport(HttpServletResponse response, SprayExportModel param) {
        estimateService.sprayExport(response, param);
    }
    /**  sprayExport 导出装配样机工时数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 11:17
     */
    @ResponseBody
    @GetMapping("/assemblyExport")
    public void assemblyExport(HttpServletResponse response, AssemblyExportModel param) {
        estimateService.assemblyExport(response, param);
    }
    /**  installExport 导出安装样机工时数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 11:17
     */
    @ResponseBody
    @GetMapping("/installExport")
    public void installExport(HttpServletResponse response, InstallExportModel param) {
        estimateService.installExport(response, param);
    }
    /**  debugExport 导出调试样机工时数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 11:17
     */
    @ResponseBody
    @GetMapping("/debugExport")
    public void debugExport(HttpServletResponse response, DebugExportModel param) {
        estimateService.debugExport(response, param);
    }
    /**  designExport 设计工时导出
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/5 9:46
     */
    @ResponseBody
    @GetMapping("/designExport")
    public void designExport(HttpServletResponse response, DesignExportModel param) {
        estimateService.designExport(response, param);
    }
    /**  packingExport 打包工时导出
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/5 17:49
     */
    @ResponseBody
    @GetMapping("/packingExport")
    public void packingExport(HttpServletResponse response, PackingExportModel param) {
        estimateService.packingExport(response, param);
    }
    /**  packingAuxExport 包装辅材导出
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/5 17:49
     */
    @ResponseBody
    @GetMapping("/packingAuxExport")
    public void packingAuxExport(HttpServletResponse response, PackingAuxExportModel param) {
        estimateService.packingAuxExport(response, param);
    }
    /**  transportExport 运输费导出
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/5 20:05
     */
    @ResponseBody
    @GetMapping("/transportExport")
    public void transportExport(HttpServletResponse response, TransportExportModel param) {
        estimateService.transportExport(response, param);
    }
    /**  designWeightExport 设计重量导出
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/5 10:04
     */
    @ResponseBody
    @GetMapping("/designWeightExport")
    public void designWeightExport(HttpServletResponse response, DesignWeightExportModel param) {
        estimateService.designWeightExport(response, param);
    }
    /**  auxExport 导出安装样机辅材数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2021/1/4 20:30
     */
    @ResponseBody
    @GetMapping("/auxExport")
    public void auxExport(HttpServletResponse response, AuxExportModel param) {
        estimateService.auxExport(response, param);
    }
    /**  heatTreatmentExport 导出热处理重量数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 20:19
     */
    @ResponseBody
    @GetMapping("/heatTreatmentExport")
    public void heatTreatmentExport(HttpServletResponse response, HeatTreatmentExportModel param) {
        estimateService.heatTreatmentExport(response, param);
    }
    /**  sprayExport 导出装配样机辅材数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 11:17
     */
    @ResponseBody
    @GetMapping("/assemblyAuxExport")
    public void assemblyAuxExport(HttpServletResponse response, AssemblyAuxExportModel param) {
        estimateService.assemblyAuxExport(response, param);
    }
    /**  sprayAuxExport 导出喷涂样机辅材数据
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/30 11:17
     */
    @ResponseBody
    @GetMapping("/sprayAuxExport")
    public void sprayAuxExport(HttpServletResponse response, SprayAuxExportModel param) {
        estimateService.sprayAuxExport(response, param);
    }
    /**  macHoursExport 机加工时导出
     * @param response
     * @param param
     * @return void
     * @author 徐一贺
     * @date 2020/12/29 20:37
     */
    @ResponseBody
    @GetMapping("/macHoursExport")
    public void macHoursExport(HttpServletResponse response, MacHoursExportModel param) {
        estimateService.macHoursExport(response, param);
    }
    /**  deferralExport 导出铆焊样机辅材数据
     * @param response
     * @param param 条件
     * @author 徐一贺
     * @date 2020/12/24 19:06
     */
    @ResponseBody
    @GetMapping("/rivetAndSolderAuxExport")
    public void rivetAndSolderAuxExport(HttpServletResponse response, BusGeneralHoursModel param) {
        estimateService.rivetAndSolderAuxExport(response, param);
    }

    /**  getRawMatAmount 获取原材料金额
     * @param param id 成本项主键
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 9:31
     */
    @ResponseBody
    @PostMapping("/getRawMatAmount")
    public JsonResult getRawMatAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getRawMatAmount(param));
    }

    /**  getCutAmount 获取制造费金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 20:22
     */
    @ResponseBody
    @PostMapping("/getCutAmount")
    public JsonResult getCutAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getCutAmount(param));
    }
    /**  getCutAmount 获取外购费金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 20:22
     */
    @ResponseBody
    @PostMapping("/getPurAmount")
    public JsonResult getPurAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getPurAmount(param));
    }
    /**  getWholeAmount 获取整体外协金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 20:22
     */
    @ResponseBody
    @PostMapping("/getWholeAmount")
    public JsonResult getWholeAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getWholeAmount(param));
    }
    /**  getWithMatAmount 获取带料外协金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 20:22
     */
    @ResponseBody
    @PostMapping("/getWithMatAmount")
    public JsonResult getWithMatAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getWithMatAmount(param));
    }
    /**  getInstallArtificial 获取安装人工金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 15:40
     */
    @ResponseBody
    @PostMapping("/getInstallArtificial")
    public JsonResult getInstallArtificial(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getInstallArtificial(param));
    }
    /**  getDebugArtificial 获取调试人工金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 15:40
     */
    @ResponseBody
    @PostMapping("/getDebugArtificial")
    public JsonResult getDebugArtificial(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getDebugArtificial(param));
    }
    /**  getInstallAux 获取安装辅材金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 15:40
     */
    @ResponseBody
    @PostMapping("/getInstallAux")
    public JsonResult getInstallAux(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getInstallAux(param));
    }
    /**  getTransportCostTotalPrice 获取运输金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 19:24
     */
    @ResponseBody
    @PostMapping("/getTransportCostTotalPrice")
    public JsonResult getTransportCostTotalPrice(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getTransportCostTotalPrice(param));
    }
    /**  getSparePartsAmount 获取备品备件金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/6 9:47
     */
    @ResponseBody
    @PostMapping("/getSparePartsAmount")
    public JsonResult getSparePartsAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getSparePartsAmount(param));
    }

    /**  getSparePartsAmount 获取随机备件金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/6 9:47
     */
    @ResponseBody
    @PostMapping("/getAccompanyingSparePartsAmount")
    public JsonResult getAccompanyingSparePartsAmount(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getAccompanyingSparePartsAmount(param));
    }

    /**  getDesignCostTotalPrice 获取设计费成本项金额
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 8:23
     */
    @ResponseBody
    @PostMapping("/getDesignCostTotalPrice")
    public JsonResult getDesignCostTotalPrice(BusBudgetAccountingCostModel param){
        return success().setData(estimateService.getDesignCostTotalPrice(param));
    }

    /**
     * workingHoursOrAuxiliaryList 通过条件获取工时 辅材 总重 运费 数据
     * @param param 参数
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/11/5 15:28
     */
    @ResponseBody
    @PostMapping("/workingHoursOrAuxiliaryList")
    public JsonResult workingHoursOrAuxiliaryList(BusGeneralHoursModel param) {
        BusBudgetAccountingCostModel costInfo = estimateService.getBusBudgetAccountingCostModelByPrimaryKey(param.getId());
        BusGeneralHoursModel condition = new BusGeneralHoursModel();
        BeanUtil.copy(param, condition);
        condition.setDataUseType(3);
        BusMachiningHoursModel macCondition = new BusMachiningHoursModel();
        condition.setPart(costInfo.getPart());
        condition.setMajor(costInfo.getMajor());
        if (costInfo.getCode().contains("-制造费-下料")) {

            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("7");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("8");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("9");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("4");
            } else if ("辅材".equals(param.getDataType())) {
                condition.setLaborTypes("5");
            }
        } else if (costInfo.getCode().contains("-制造费-铆焊")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("13");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("14");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("15");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("6");
            } else if ("辅材".equals(param.getDataType())) {
                condition.setLaborTypes("7");
            }
        } else if (costInfo.getCode().contains("-制造费-机加")) {
            macCondition.setBatId(costInfo.getBatId());
            macCondition.setMajor(costInfo.getMajor());
            macCondition.setPart(costInfo.getPart());
            macCondition.setType(2);
            macCondition.setDataUseType(3);
            macCondition.setCostId(costInfo.getId());
            macCondition.setIsEffectiveFlag(param.getIsEffectiveFlag());
            startPage();
            List<BusMachiningHoursModel> list = estimateService.findBusMachiningHoursModelListByEstCondition(macCondition);
            return jsonResult(list);
        } else if (costInfo.getCode().contains("-制造费-喷涂")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("25");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("26");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("27");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("9,11");
            } else if ("辅材".equals(param.getDataType())) {
                condition.setLaborTypes("10,12");
            }
        } else if (costInfo.getCode().contains("-制造费-装配")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("31");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("32");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("33");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("13");
            } else if ("辅材".equals(param.getDataType())) {
                condition.setLaborTypes("14");
            }
        } else if (costInfo.getCode().contains("-制造费-热处理")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("19");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("20");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("21");
            }
            if ("重量".equals(param.getDataType())) {
                condition.setLaborTypes("8");
            }
        } else if (costInfo.getCode().contains("-现场安装费-人工-安装人工")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("38");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("39");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("40");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("18");
            }
        } else if (costInfo.getCode().contains("-现场安装费-人工-调试人工")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("1");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("2");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("3");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("20");
            }
        } else if (costInfo.getCode().contains("-现场安装费-辅材")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("38");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("39");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("40");
            }
            if ("辅材".equals(param.getDataType())) {
                condition.setLaborTypes("19");
            }
        } else if (costInfo.getCode().contains("-设计费")) {
            if ("机械".equals(costInfo.getMajor())) {
                condition.setTypes("1");
            } else if ("流体".equals(costInfo.getMajor())) {
                condition.setTypes("2");
            } else if ("自动化".equals(costInfo.getMajor())) {
                condition.setTypes("3");
            }
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("1");
            }else if ("重量".equals(param.getDataType())) {
                condition.setLaborTypes("2,3");
            }
        } else if (costInfo.getCode().contains("包装运输费-包装费")) {
            condition.setPart(null);
            condition.setMajor(null);
            condition.setTypes("34");
            if ("工时".equals(param.getDataType())) {
                condition.setLaborTypes("15");
            } else if ("辅材".equals(param.getDataType())) {
                condition.setLaborTypes("16");
            }
        } else if (costInfo.getCode().contains("包装运输费-运输费")) {
            condition.setPart(null);
            condition.setMajor(null);
            condition.setTypes("34");
            if ("运输费".equals(param.getDataType())) {
                condition.setLaborTypes("17");
            }
        }
        startPage();
        List<BusGeneralHoursModel> listHours = estimateService.findBusGeneralHoursModelListByCondition(condition);
        return jsonResult(listHours);
    }

    /**  cutHoursSaveAdd 添加工时 辅材 运费数据
     * @param param 数据
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/25 19:21
     */
    @ResponseBody
    @PostMapping("/cutHoursSaveAdd")
    public JsonResult cutHoursSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  heatTreatmentHoursSaveAdd 添加热处理
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/30 19:32
     */
    @ResponseBody
    @PostMapping("/heatTreatmentHoursSaveAdd")
    public JsonResult heatTreatmentHoursSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  auxSaveAdd 添加现场安装辅材
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 20:16
     */
    @ResponseBody
    @PostMapping("/auxSaveAdd")
    public JsonResult auxSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  auxSaveUpdate 更新现场安装辅材
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 20:16
     */
    @ResponseBody
    @PostMapping("/auxSaveUpdate")
    public JsonResult auxSaveUpdate(BusGeneralHoursModel param){
        return estimateService.auxSaveUpdate(param);
    }
    /**  updateTransportSave 更新运输费
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 19:58
     */
    @ResponseBody
    @PostMapping("/updateTransportSave")
    public JsonResult updateTransportSave(BusGeneralHoursModel param){
        return estimateService.updateTransportSave(param);
    }


    /**  getResultMacHours 获取机加计算结果
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 11:27
     */
    @ResponseBody
    @PostMapping("/getResultMacHours")
    public JsonResult getResultMacHours(GetResultMacHoursModel param){
        return success().setData(estimateService.getResultMacHours(param));
    }

    /**  loadProcessList 加载工序列表
     * @param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 16:30
     */
    @ResponseBody
    @PostMapping("/loadProcessList")
    public JsonResult loadProcessList(){
        return success().setData(estimateService.loadProcessList());
    }
    /**  loadNameTypeList 加载设备类型列表
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 16:30
     */
    @ResponseBody
    @PostMapping("/loadNameTypeList")
    public JsonResult loadNameTypeList(){
        return success().setData(estimateService.loadNameTypeList());
    }
    /**  loadNameList 根据设备类型获取设备列表
     * @param nameType 设备类型
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 16:57
     */
    @ResponseBody
    @PostMapping("/loadNameList")
    public JsonResult loadNameList(String nameType){
        return success().setData(estimateService.loadNameList(nameType));
    }

    /**  macSaveAdd 添加机加工时
     * @param param 机加工时
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 18:57
     */
    @ResponseBody
    @PostMapping("/macSaveAdd")
    public JsonResult macSaveAdd(BusMachiningHoursModel param){
        Integer result = estimateService.macSaveAdd(param);
        if(result>0){
            return success("添加机加工时成功！");
        }
        return error("添加机加工时失败！");
    }
    /**  macSaveEdit 编辑机加工时
     * @param param 机加工时
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/29 18:57
     */
    @ResponseBody
    @PostMapping("/macSaveEdit")
    public JsonResult macSaveEdit(BusMachiningHoursModel param){
        Integer result = estimateService.macSaveEdit(param);
        if(result>0){
            return success("编辑机加工时成功！");
        }
        return error("编辑机加工时失败！");
    }

    /**  spraySave 保存编辑喷涂
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/30 14:02
     */
    @ResponseBody
    @PostMapping("/spraySave")
    public JsonResult spraySave(BusGeneralHoursModel param){
        Integer result = estimateService.spraySave(param);
        if(result>0){
            return success("编辑喷涂成功！");
        }
        return error("编辑喷涂失败！");
    }

    /**  purList 外购件列表
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/31 8:32
     */
    @ResponseBody
    @PostMapping("/purList")
    public JsonResult purList(BusMaterialDataModel param){
        startPage();
       return jsonResult(estimateService.purList(param));
    }
    /**  wholeList 整体外协
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 12:39
     */
    @ResponseBody
    @PostMapping("/wholeList")
    public JsonResult wholeList(BusMaterialDataModel param){
        startPage();
       return jsonResult(estimateService.wholeList(param));
    }
    /**  whishMatList 带料外协
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 12:47
     */
    @ResponseBody
    @PostMapping("/whishMatList")
    public JsonResult whishMatList(BusMaterialDataModel param){
        startPage();
       return jsonResult(estimateService.whishMatList(param));
    }
    /**  loadMatDescList 获取提包描述下拉框
     * @param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/31 12:45
     */
    @ResponseBody
    @PostMapping("/loadMatDescList")
    public JsonResult loadMatDescList(String keyStr){
        return success().setData(estimateService.findMatDescList(10,keyStr));
    }
    /**  purSave 添加或保存编辑外购费
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2020/12/31 14:33
     */
    @ResponseBody
    @PostMapping("/purSave")
    public JsonResult purSave(BusMaterialDataModel param){
        return estimateService.purSave(param);
    }

    /**  installHoursSaveAdd 安装工时添加
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 16:48
     */
    @ResponseBody
    @PostMapping("/installHoursSaveAdd")
    public JsonResult installHoursSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  transportSaveAdd 运输费添加
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 19:49
     */
    @ResponseBody
    @PostMapping("/transportSaveAdd")
    public JsonResult transportSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  installHoursSaveAdd 包装工时添加
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 16:48
     */
    @ResponseBody
    @PostMapping("/packingHoursSaveAdd")
    public JsonResult packingHoursSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  updateInstallHoursSave 更新安装工时
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 18:11
     */
    @ResponseBody
    @PostMapping("/updateInstallHoursSave")
    public JsonResult updateInstallHoursSave(BusGeneralHoursModel param) {
        return estimateService.updateInstallHoursSave(param);
    }
    /**  updatePackingHoursSave 更新打包工时
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 16:49
     */
    @ResponseBody
    @PostMapping("updatePackingHoursSave")
    public JsonResult updatePackingHoursSave(BusGeneralHoursModel param) {
        return estimateService.updatePackingHoursSave(param);
    }
    /**  updatePackingAuxSave 更新打包辅材
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 17:45
     */
    @ResponseBody
    @PostMapping("updatePackingAuxSave")
    public JsonResult updatePackingAuxSave(BusGeneralHoursModel param) {
        return estimateService.updatePackingAuxSave(param);
    }
    /**  installHoursSaveAdd 安装工时添加
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 16:48
     */
    @ResponseBody
    @PostMapping("/debugHoursSaveAdd")
    public JsonResult debugHoursSaveAdd(BusGeneralHoursModel param){
        return estimateService.cutHoursSaveAdd(param);
    }
    /**  updateInstallHoursSave 更新安装工时
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/4 18:11
     */
    @ResponseBody
    @PostMapping("/updateDebugHoursSave")
    public JsonResult updateDebugHoursSave(BusGeneralHoursModel param) {
        return estimateService.updateDebugHoursSave(param);
    }
    /**  updateDsnHoursSave 更新设计工时
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/5 8:58
     */
    @ResponseBody
    @PostMapping("/updateDsnHoursSave")
    public JsonResult updateDsnHoursSave(BusGeneralHoursModel param) {
        return estimateService.updateDsnHoursSave(param);
    }

    /**
     * submitList 跳转到概算成本审核列表
     *
     * @return java.lang.String
     * @author 徐一贺
     * @date 2020/11/10 20:08
     * @version 1.0
     */
    @GetMapping("/approvalList")
    @RequiresPermissions("rou:audit:view")
    public String approvalList() {
        return "estimateManage/approval/page";
    }

    /**
     * showAccCostSheet 跳转到成本项审核查看页
     *
     * @param batId 单据表主键
     * @param model 渲染模型
     * @return java.lang.String
     * @throws
     * @author 徐一贺
     * @date 2020/11/23 14:51
     */
    @GetMapping("/showEstCostSheetByApproval/{batId}/{id}/{mode}")
    public String showAccCostSheetByApproval(
            @PathVariable("batId") Integer batId,
            @PathVariable("id") Integer id,
            @PathVariable("mode") String mode,
            Model model) {
        BusBudgetAccountingTaskModel order =
                accountingService.getBusBudgetAccountingTaskAndAppInfoByPrimaryKey(batId);
        // 获取驳回列表数据
        List<AccountingProjectModel> rejectList = accountingService.findVerifyProcessByBatId(batId);
        AccountingProjectModel accountingProjectModel1 =
                accountingService.getEstVerifyProcessId(batId, ShiroUtils.getUserId());
        if (accountingProjectModel1 != null) {
            order.setVerifyProcessId(
                    accountingService.getEstVerifyProcessId(batId, ShiroUtils.getUserId()).getId());
        }
        ProjectModel project = getDataService.getProjectModel(order.getProCode());
        List<BusBudgetAccountingCost> costList =
                accountingService.findShowBusBudgetAccountingCostByBatId(batId);
        // 基础参数数据
        List<BusBudgetAccountingBasicInfoConfig> busBudgetAccountingBasicInfoConfigList =
                getDataService.findBusBudgetAccountingBasicInfoConfigByBatId(batId);
        // 获取核算设备总重
        BigDecimal equipmentTotalWeight =
                getDataService.getAccountingEquipmentTotalWeightByBatId(batId).divide(new BigDecimal(project.getNum()), 2, BigDecimal.ROUND_HALF_UP);
        // 获取核算设备净重
        BigDecimal equipmentTotalNetWeight =
                getDataService.getAccountingEquipmentTotalNetWeightByBatId(batId).divide(new BigDecimal(project.getNum()), 2, BigDecimal.ROUND_HALF_UP);
        model.addAttribute("rejectList", rejectList);
        model.addAttribute("order", order);
        model.addAttribute("project", project);
        model.addAttribute("mode", mode);
        model.addAttribute("busBudgetAccountingCosts", costList);
        model.addAttribute(
                "busBudgetAccountingBasicInfoConfigList", busBudgetAccountingBasicInfoConfigList);
        model.addAttribute("equipmentTotalWeight", equipmentTotalWeight);
        model.addAttribute("equipmentTotalNetWeight", equipmentTotalNetWeight);
        return "estimateManage/approval/costSheet/page";
    }

    /**  estimatingApproval 概算审核
     * @param param
     * @return com.zhongwang.business.common.JsonResult
     * @author 徐一贺
     * @date 2021/1/8 10:39
     */
    @ResponseBody
    @PostMapping("/estimatingApproval")
    public JsonResult estimatingApproval(AccountingProjectModel param) {
        return estimateService.estimatingApproval(param);
    }

    /**  queryPage 核算成本清单查询
     * @param model
     * @return java.lang.String
     * @author 徐一贺
     * @date 2021/1/8 12:42
     */
    @GetMapping("/queryPage")
    @RequiresPermissions("rou:query:vew")
    public String queryPage(Model model) {
        // 获取工作组列表
        List<BusinessGroupModel> groupModelList = accountingService.findBusinessGroupList();
        model.addAttribute("groupModelList", groupModelList);
        return "estimateManage/query/page";
    }
    /**
     * queryList 查询列表
     *
     * @param param 查询参数
     * @return com.zhongwang.business.common.JsonResult
     * @throws
     * @author 徐一贺
     * @date 2020/11/30 20:05
     */
    @ResponseBody
    @PostMapping("/queryList")
    public JsonResult queryList(AccountingProjectModel param) {
        startPage();
        return jsonResult(estimateService.queryList(param));
    }
}